import { merge, each } from 'lodash'
import { eLineOptions } from './chartOptions'

export default {
  data() {
    return {
      xxygqxVisible: false,
      xxyqquTpl: null
    }
  },
  computed: {
    xxyqqxData() {
      const _xAiaxList = []
      const _serList = []
      const _pList = []
      each(this.abnormalList, item => {
        const { hour, usage, ...rest } = item
        _xAiaxList.push(hour)
        _serList.push({
          hour,
          name: hour,
          value: usage,
          ...rest
        })
        _pList.push(usage)
      })
      return merge({}, eLineOptions, {
        xAxis: {
          data: _xAiaxList
        },
        series: [
          {
            type: 'line',
            data: _serList
          }
        ]
      })
    }
  },
  methods: {
    handleXsyqqx() {
      if (this.selectedCandlSerie == null) {
        return this.$Notice.warning({
          title: '操作提示',
          desc: '没有可操作的数据'
        })
      }
      this.loadAbnormalData()
      this.xxygqxVisible = true
      this.xxyqquTpl = 'ELine'
    },
    handleXsyqqxCancel() {
      this.xxygqxVisible = false
      this.xxyqquTpl = null
    }
  }
}
